import chardet  
  
def detect_encoding(file_path):  
    with open(file_path, 'rb') as f:  
        result = chardet.detect(f.read())  
    return result['encoding']  
  
file_path = r'D:\yolov5-5.0\UI.py'  # 你的文件路径  

encoding = detect_encoding(file_path)  
print(encoding)  # 打印出猜测的编码